package com.example.dddsample.application.service;

import com.example.dddsample.application.api.request.KafkaRequestDTO;
import com.example.dddsample.application.assembler.KafkaRequestDTOAssembler;
import com.example.dddsample.domain.entity.KafkaAggregate;
import com.example.dddsample.domain.service.KafkaService;
import org.springframework.stereotype.Service;

/**
 * @author: bebm
 * @date: 2022/4/6 17:02
 * @description:
 */
@Service
public class KafkaAppService {

    /**
     * kafkaService
     */
    private final KafkaService kafkaService;

    private final KafkaRequestDTOAssembler kafkaRequestDTOAssembler;

    /**
     * KafkaAppService
     * @param kafkaService kafkaService
     */
    private  KafkaAppService(KafkaService kafkaService,
                             KafkaRequestDTOAssembler kafkaRequestDTOAssembler){
        this.kafkaService=kafkaService;
        this.kafkaRequestDTOAssembler=kafkaRequestDTOAssembler;
    }

    /**
     *
     * @param kafkaRequestDTO
     */
    public void createTopic(KafkaRequestDTO kafkaRequestDTO) {
        KafkaAggregate kafkaAggregate =kafkaRequestDTOAssembler
                .assemblerFromKafkaRequestDTO(kafkaRequestDTO);
        kafkaService.createTopic(kafkaAggregate);

    }

    /**
     *
     * @param kafkaRequestDTO
     */
    public void deleteTopic(KafkaRequestDTO kafkaRequestDTO) {
        KafkaAggregate kafkaAggregate =kafkaRequestDTOAssembler
                .assemblerFromKafkaRequestDTO(kafkaRequestDTO);
        kafkaService.deleteTopic(kafkaAggregate);

    }
}
